package com.uaroadshow.entity.user;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

/**
 * 买单用户信息
 * 
 * @author mohanlan
 *
 */
@Entity
@Table(name= "user_info")
@JsonIgnoreProperties(value = { "hibernate_lazy_initializer", "handler", "fieldHandler" })
public class UserInfo {
    
    @Id
    @GeneratedValue
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
    @JsonIdentityReference(alwaysAsId = true)
    private User user;
    
    /** 姓名 */
    private String name;
    
    /** 性别 */
    private String gender;
    
    /** 年龄 */
    private Integer age;
    
    /** 短袖尺码 */
    private String clothesSize;
    
    /** 鞋子尺码 */
    private String shoeSize;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public UserInfo() {
    }
    
    public UserInfo(User user) {
        this.disabled = false;
        this.user = user;
    }

    /**
     * @param name
     * @param gender
     * @param age
     * @param clothesSize
     * @param shoeSize
     * @return
     */
    public UserInfo edit(String name, String gender, Integer age, String clothesSize, String shoeSize) {
        this.name = StringUtils.isNotBlank(name) ? name : this.name;
        this.gender = StringUtils.isNotBlank(gender) ? gender : this.gender;
        this.age = age != null ? age : this.age;
        this.clothesSize = StringUtils.isNotBlank(clothesSize) ? clothesSize : this.clothesSize;
        this.shoeSize = StringUtils.isNotBlank(shoeSize) ? shoeSize : this.shoeSize;;
        return this;
    }
    
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the gender
     */
    public String getGender() {
        return gender;
    }

    /**
     * @return the age
     */
    public Integer getAge() {
        return age;
    }

    /**
     * @return the clothesSize
     */
    public String getClothesSize() {
        return clothesSize;
    }

    /**
     * @return the shoeSize
     */
    public String getShoeSize() {
        return shoeSize;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param gender the gender to set
     */
    public void setGender(String gender) {
        this.gender = gender;
    }

    /**
     * @param age the age to set
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    /**
     * @param clothesSize the clothesSize to set
     */
    public void setClothesSize(String clothesSize) {
        this.clothesSize = clothesSize;
    }

    /**
     * @param shoeSize the shoeSize to set
     */
    public void setShoeSize(String shoeSize) {
        this.shoeSize = shoeSize;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
    
}